﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MySql.Data.MySqlClient;

public partial class _index : System.Web.UI.Page
{
    static MySql.Data.MySqlClient.MySqlConnection connection = new MySqlConnection(GetConnectionString());

    protected void Page_Load(object sender, EventArgs e)
    {

        MySql.Data.MySqlClient.MySqlConnection mycon = new MySqlConnection(GetConnectionString());

        try
        {
            mycon.Open();
       
        }
        catch (MySqlException ex)
        {
            
            throw (ex);

        }
    }
    public static string GetConnectionString()
    {
        string connStr = String.Format("server={0};user id={1}; password={2};" +
          "database=cs490; pooling=false", "bai.bounceme.net",
          "root", "purdue");

        return connStr;
    }
    static public Dictionary<String, String> getCountries()
    {
        MySqlCommand command = connection.CreateCommand();
        MySqlDataReader reader = null;
        Dictionary<String, String> returndict = new Dictionary<String, String>();
        command.CommandText = "select * from countries";
        connection.Open();
        reader = command.ExecuteReader();
        while (reader.Read())
        {
            returndict.Add(reader.GetString(1), reader.GetString(2));
        }
        connection.Close();

        return returndict;
    }
}